package org.poptest.junit4;

import org.junit.runners.model.FrameworkMethod;
import org.poptest.bootstrap.Bootstrapper;

import java.lang.reflect.Method;

/**
 * @author Alan Roche
 *         Date: 26/01/11
 *         Time: 22:22
 */
public class BootstrapFrameworkMethod extends ParameterizedFrameworkMethod {
    private final Bootstrapper bootStrapper;
    public BootstrapFrameworkMethod(final Bootstrapper bootStrapper, final Class<?> keyClass, final FrameworkMethod method) {
        super(keyClass, method);
        this.bootStrapper = bootStrapper;
    }

    public BootstrapFrameworkMethod(final Bootstrapper bootStrapper, final Class<?> keyClass, final Method method) {
        super(keyClass, method);
        this.bootStrapper = bootStrapper;
    }

     public BootstrapFrameworkMethod(final Bootstrapper bootStrapper, final Class<?> keyClass) {
        super(keyClass, getDummyMethod());
        this.bootStrapper = bootStrapper;
    }


    protected static Method getDummyMethod() {
        try {
            return BootstrapFrameworkMethod.class.getMethod("_before");
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }

    }

    public void _before() {
        // no-op
    }

     protected static Method getBeforeClassDummyMethod() {
        try {
            return BootstrapFrameworkMethod.class.getMethod("_beforeClass");
        } catch (NoSuchMethodException e) {
            throw new RuntimeException(e);
        }

    }

    public static void _beforeClass() {
        // no-op
    }
}


